//
//  LoadingView.m
//  easyTaxi
//
//  Created by ellenpage on 13-2-27.
//  Copyright (c) 2013年 ellenpage. All rights reserved.
//

#import "MyLoadingView.h"
#import "Constant.h"

@implementation MyLoadingView

- (id)init
{
    self = [super init];
    if (self)
    {        
        backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, iP5 ? 568 : 480)];
        backgroundView.backgroundColor = [[UIColor darkTextColor] colorWithAlphaComponent:0.9];
        
        _waitingLbl = [[UILabel alloc] init];

        UIImageView *bgImageView = [[UIImageView alloc] init];
        if (!iP5)
        {
            bgImageView.frame = CGRectMake(0, 0, 320, 480);
            bgImageView.image = [UIImage imageNamed:@"Default.png"];
            _waitingLbl.frame = CGRectMake(0, 422, 320, 24);
        }
        else
        {
            bgImageView.frame = CGRectMake(0, 0, 320, 568);
            bgImageView.image = [UIImage imageNamed:@"Default~iphone.png"];
            _waitingLbl.frame = CGRectMake(0, 504, 320, 24);
        }
        
        [backgroundView addSubview:bgImageView];
        
        _waitingLbl.textAlignment = UITextAlignmentCenter;
        _waitingLbl.text = @"正在获取当前位置...";
        _waitingLbl.font = [UIFont systemFontOfSize:18];
        _waitingLbl.backgroundColor = [UIColor clearColor];
        _waitingLbl.textColor       = [UIColor blackColor];
        [backgroundView addSubview:_waitingLbl];
        
    }
    return self;
}

//显示进度滚轮指示器
-(void)showWaiting:(UIView *)parentView
{
    [parentView addSubview:backgroundView];
}

//消除滚动轮指示器
-(void)hideWaiting
{
    [backgroundView removeFromSuperview];
}

- (void)showText:(NSString *)string
{
    _waitingLbl.text = string;
}

@end
